<!DOCTYPE HTML>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>briup电子商务-注册页</title>
    <link rel="stylesheet" href="css/common.css"/>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div class="container2">
    <div class="header2">
        <div>
            <a href="index.jsp"><img class="logo" src="images/log2.png"></a>
        </div>
        <div>
            <ul class="tabs">
                <li class="phone current">
                    <%= request.getAttribute("key1") == null ? "用手机登陆" : request.getAttribute("key1")%>
                </li>
            </ul>
        </div>
        <div class="tlg">
            已有账号 <a href="login.jsp">登录</a>
        </div>
    </div>
    <div class="content2">
        <form action="http://localhost:8686/estore/regist" method="post">
            <ul class="reg_box">
                <li id="li_name">
                    <span><b>*</b>用户名：</span>
                    <input id="name" type="text" name="username" value="" placeholder="请输入2~4位用户名"/>
                </li>
                <li>
                    <span><b>*</b>密码：</span>
                    <input id="password" type="password" name="password" value="" placeholder="请输入6~8位密码"/>
                </li>
                <li>
                    <span><b>*</b>邮编：</span>
                    <input id="zip" type="text" name="zip" placeholder="请输入邮编"/>
                </li>
                <li>
                    <span><b>*</b>地址：</span>
                    <input id="address" type="text" name="address" placeholder="请输入地址信息"/>
                </li>
                <li>
                    <span><b>*</b>电话：</span>
                    <input id="phone" type="text" name="phone" placeholder="请输入电话号码"/>
                </li>
                <li>
                    <span><b>*</b>电子邮箱：</span>
                    <input type="text" id="email" name="email" placeholder="请输入合法邮箱地址"/>
                </li>

            </ul>
            <p>
                <input id="aaa" type="checkbox" checked/>
                我已阅读并同意
                <a href="#">用户注册协议</a>
            </p>
            <input class="btn_submit" type="submit" value="立即注册" onclick="return check();"/>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
	
	function check() {
		var name = document.getElementById("name").value;
		var password = document.getElementById("password").value;
		var zip = document.getElementById("zip").value;
		var address = document.getElementById("address").value;
		var phone = document.getElementById("phone").value;
		var email = document.getElementById("email").value;
		var emailtext =/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/;
		var nametext=/^\w{2,4}$/;
		var ziptext =  /^[1-9][0-9]{5}$/;
		var passwordtext=/^\w{6,8}$/;
		var phonetext =/^1[0-9]{10}$/;
		if (name == "") {
			alert("请输入用户名！！！");
			return false;
		}
		if (!nametext.test(name)){
		    alert("用户名不合法！！！");
            return false;
         }
		if (password == "") {
			alert("请输入密码！！！");
			return false;
		}
		if (!passwordtext.test(password)){
		    alert("密码不合法！！！");
            return false;
        }
		if (zip == ""){
		    alert("请输入邮编！！！");
            return false
        }
		if (!ziptext.test(zip)){
		    alert("邮编不合法！！！");
            return false
        }
		if (address == ""){
		    alert("请输入地址！！！");
            return false
        }
		if(phone == ""){
		    alert("请输入手机号！！！");
            return false
        }
		if(!phonetext.test(phone)){
		    alert("请输入正确的手机号！！！");
            return false
        }
		if (email == ""){
		    alert("请输入邮箱！！！");
            return false
        }
		if (!emailtext.test(email)){
		    alert("邮箱不合法！！！");
            return false
        }
	}
</script>
</html>
